package queueUtils

import (
	"ustcLab/server/dao/bean"
)

type Queue struct {
	nums []*bean.DashBoardResponse
}

var ins *Queue

func GetQueue() *Queue {
	if ins == nil {
		ins = &Queue{make([]*bean.DashBoardResponse, 0)}
	}
	return ins
}
func (s *Queue) Push(n *bean.DashBoardResponse) {
	ins.nums = append(ins.nums, n)
}
func (s *Queue) Pull() (*bean.DashBoardResponse, error) {
	node := &bean.DashBoardResponse{
		Data:             nil,
		NServer:          "",
		IsInEmergency:    false,
		MessageEmergency: "",
	}
	if len(ins.nums) > 0 {
		node = ins.nums[0]
		ins.nums = ins.nums[1:]
	}
	return node, nil
}
